package com.orange.modules.dao;

import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.orange.dbhelp.DbHelper;
import com.orange.modules.entity.AuthCatalog;

@Repository
public class AuthCatalogRepository {
	
	@Resource(name = "dbHelper")
	private DbHelper dbHelper;
	
	@Autowired
	private AuthCatalogDao authCatalogDao;
	
	/**
	 * 根据父目录ID查询子目录信息
	 * @param fid
	 * @return
	 * @throws SQLException
	 */
	public List<AuthCatalog> queryCatalog(String fid) throws SQLException{
		String sql = "SELECT t.p_id as pid,t.catalog_name as catalogName,"
				+ "t.f_id as fid,t.s_createtime as createtime ,t.f_fid as ffid,t.f_fname as ffname FROM t_auth_catalog t WHERE 1=1 ";
		if(fid!=null && StringUtils.isNotBlank(fid))
			sql+=" AND t.f_id ='"+fid+"'";
		List<AuthCatalog> list = dbHelper.getBeanList(sql, AuthCatalog.class, null);
		return list;
	}
	
}
